﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using FuturamaKassa.Objects;
using FuturamaKassa.Database;

namespace FuturamaKassa.Commands.ReceiveCommands {
    class GetInventory : ReceiveCommand {

        public override void Execute(List<byte> response) {

            response.RemoveRange(0, 10);
            response.RemoveRange(response.Count - 2, 2);

            List<string> idList = RFIDFunctions.SplitByNumber(Encoding.ASCII.GetString(response.ToArray()), 16);

            idList = RFIDFunctions.revertBitOrder(idList);

            DataService data = new DataService();
            data.getTags(idList);

            Console.WriteLine("Command Get Inventory (6C21) executed");

            Inventory.GetInstance().Products = idList;
            Inventory.GetInstance().Wait = false;
        }
    }
}
